<template>
	<view class="news-content">
		<view v-for="(items, index) in newsList" :key="index" class="new-list">
			<view>
				<view class="news-name"> 消息服务 </view>
				<view class="news-value"> {{ items.content}} </view>
			</view>
			<view class="news-time"> {{ items.create_time }} </view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				newsList: []
			}
		},
		created() {
			this.getList();
		},
		methods: {
			getList() {
				const path = {
					app: "wx",
					api: "api_wx_user_getUserMsg",
					version: "1.0",
					type: "1",
					data: {}
				}
				const _this = this;
				_this.sendSock(path, function(res) {
					_this.getSock(res.data)
				})
			},
			getSock(res) {
				if (res !== '{"type":"ping"}') {
					const resj = JSON.parse(res);
					if (resj.code === -1) {
						uni.showToast({
							icon: "none",
							title: resj.message,
							duration: 2000
						});
					} else {
						if (resj.api === "api_wx_user_login") {
							this.$store.commit('login', resj.data);
							this.temporary()
						} else if (resj.api === "api_wx_user_keepLogin") {
							this.temporary()
						} else if (resj.api === "api_wx_user_getUserMsg") {
							console.log('resj', resj)
							this.newsList = resj.data;
							
						}
					}
				}
			}
		}
	}
</script>

<style>
	page {
		background-color: #F6F6F6;
	}

	.news-content {
		padding: 0 30rpx;
	}

	.new-list {
		display: flex;
		align-items: flex-start;
		justify-content: space-between;
		background-color: #FFFFFF;
		margin-top: 30rpx;
		padding: 30rpx 20rpx;
	}

	.news-name {
		font-size: 36rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: rgba(51, 51, 51, 1);
		line-height: 1;
	}

	.news-value {
		font-size: 28rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: rgba(51, 51, 51, 1);
		line-height: 1;
		margin-top: 24rpx;
	}

	.news-time {
		font-size: 24rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: rgba(178, 178, 178, 1);
		line-height: 1;
	}
</style>
